package com.example.hospitalsystem.controller;

import com.example.hospitalsystem.pojo.dto.design.AddDesignDto;
import com.example.hospitalsystem.pojo.dto.design.DesignPageQueryDto;
import com.example.hospitalsystem.result.Result;
import com.example.hospitalsystem.service.DesignService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@Tag(name="13.设计模块")
@RestController
@RequestMapping("/design")
public class DesignController {

    @Autowired
    private DesignService designService;

    @Operation(summary = "添加设计信息", security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/addDesign")
    public Result addDesign(@RequestBody AddDesignDto addDesignDto){
        return designService.addDesign(addDesignDto);
    }

    @Operation(summary = "删除设计信息", security = {@SecurityRequirement(name = "Authorization")})
    @DeleteMapping("/deleteDesign/{id}")
    public Result deleteDesignById(@PathVariable("id") Integer id){
        return designService.deleteDesignById(id);
    }

    @Operation(summary = "获取所有设计信息")
    @PostMapping("/getAllDesign")
    public Result getAllDesign(@RequestBody DesignPageQueryDto dto){
        return designService.getAllDesign(dto);
    }

    @Operation(summary = "获取前五条设计信息")
    @GetMapping("/getTop5Design")
    public Result getTop5Design(){
        return designService.getTop5Design();
    }

    @Operation(summary = "获取前十条设计信息")
    @GetMapping("/getTop10Design")
    public Result getTop10Design(){
        return designService.getTop10Design();
    }

    @Operation(summary = "获取详细设计信息")
    @GetMapping("/getDetailShow/{id}")
    public Result getDetailShowFun(@PathVariable("id") Integer id){
        return designService.getDetailShow(id);
    }

    @Operation(summary = "上传图片信息",security = {@SecurityRequirement(name = "Authorization")})
    @PostMapping("/uploadDesign")
    public Result uploadDesignFun(@RequestParam MultipartFile image) throws IOException {
        return designService.uploadDesign(image);
    }
}
